<!DOCTYPE html>
<title>Traceur Tests</title>
<meta charset="utf-8">
<link rel="stylesheet" href="./node_modules/mocha/mocha.css">
<style>
#mocha-stats.unitTestProgress {
  top: 60px;
}
</style>
<script src="node_modules/mocha/mocha.js"></script>
<script src="node_modules/chai/chai.js"></script>
<script src="bin/traceur.js"></script>
<script>
window.System = new traceur.runtime.BrowserTraceurLoader();
System.map = System.semverMap(System.version);
</script>
<div id="mocha"></div>

<script>
function fixupMocha(mochaClass) {
  document.getElementById('mocha-stats').classList.add(mochaClass);
}
// Unit tests
var metadata = {traceurOptions: {sourceMaps: true}};
System.import('./test/unit/unitTestRunner.js', metadata).then(function(module) {
  var unitTestRunner = module.unitTestRunner;
  window.suite = module.suite;
  window.test = module.test;
  window.setup = module.setup;
  window.teardown = module.teardown;
  return unitTestRunner.run().then(function() {
    console.log('unitTestRunner success');
    fixupMocha('unitTestProgress');
  }, function(ex) {
    document.getElementById('mocha').textContent = ex.stack || ex;
    console.error('unitTestRunner.run FAILED', ex.stack || ex);
  });
}).then(function() {
  // Feature tests.
  return System.import('./test/featureTestRunner.js ', metadata).
      then(function(module) {
      	module.featureTestRunner.run().then(function() {
          console.log('featureTestRunner success');
        }, function(ex) {
          document.getElementById('mocha').textContent = ex.stack || ex;
          console.error('featureTestRunner.run FAILED', ex.stack || ex);
        });
      });
}).catch(function(ex) {
  document.getElementById('mocha').textContent = ex.stack || ex;
  console.error('import FAILED', ex.stack || ex);
});
</script>
